﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;

namespace TauschFormat2
{
    class DBUpdate
    {
        PokeDataDataSet pkData = new PokeDataDataSet();
        PokeDataDataSetTableAdapters.PokemonTableAdapter pkTableAdapter = new PokeDataDataSetTableAdapters.PokemonTableAdapter();

        public void PokeAdapter(string[] values, bool insert)
        {
            pkTableAdapter.Update(pkData.Pokemon);
            var x = from r in pkData.Pokemon select r.id;
            foreach (int r in (EnumerableRowCollection<int>)x)
            {
                pkTableAdapter.Delete(r);
            }
            if (insert)
            {
                pkTableAdapter.Update(pkData.Pokemon);
                for (int i = 0; i < values.Length; i++)
                {
                    pkData.Pokemon.AddPokemonRow(values[i]);
                }
                pkTableAdapter.Update(pkData.Pokemon);
            }
        }
    }
}
